home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / private / _xfrmlin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-29  |  4.1 KB  |  182 lines

  1. #ifndef NO_MEMORY_H
  2. #include <memory.h>
  3. #endif
  4. #define    CURSES_LIBRARY    1
  5. #include <curses.h>
  6.  
  7.  
  8. #ifdef PDCDEBUG
  9. char *rcsid__xfrmlin = "$Header: C:\CURSES\private\RCS\_xfrmlin.c 2.1 1993/06/18 20:23:56 MH Rel MH $";
  10. #endif
  11.  
  12.  
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   PDC_transform_line()    - transform
  18.  
  19.   PDCurses Description:
  20.      This is a private PDCurses function.
  21.  
  22.      Updates the given physical line to look like the corresponding
  23.      line in _curscr.
  24.  
  25.   PDCurses Return Value:
  26.      This routine returns TRUE if a premature refresh end
  27.      is allowed, and there is an input character pending.  Otherwise,
  28.      FALSE is returned.
  29.  
  30.   PDCurses Errors:
  31.      No errors are defined for this routine.
  32.  
  33.   Portability:
  34.      PDCurses    bool    PDC_transform_line( int lineno );
  35.  
  36. **man-end**********************************************************************/
  37.  
  38. bool    PDC_transform_line(register int lineno)
  39. {
  40. #if defined (MSC) && defined (DOS)
  41. chtype*    dstp;
  42. chtype*    srcp;
  43. #else
  44. register chtype*    dstp;
  45. register chtype*    srcp;
  46. #endif
  47.  
  48. #ifdef DOS
  49. #if SMALL || MEDIUM
  50. struct SREGS segregs;
  51. int ds;
  52. #endif
  53. #endif
  54.  
  55.     int        x;
  56.     int        endx;
  57.     int        len;
  58.     chtype*    ch;
  59.     extern unsigned    char atrtab[MAX_ATRTAB];
  60.     chtype temp_line[256]; /* this should be enough for the maximum width of a screen. MH-920715 */
  61.     chtype chr;
  62.     register int j;
  63.     WINDOW *twin=curscr;
  64.  
  65. #ifdef    FLEXOS
  66.     char    line[80];
  67.     char    attr[80];
  68.     FFRAME    sframe;
  69.     RECT    drect;
  70.     RECT    srect;
  71. #endif
  72.  
  73. #ifdef PDCDEBUG
  74.     if (trace_on) PDC_debug("PDC_transform_line() - called\n");
  75. #endif
  76.  
  77.     if (twin == (WINDOW *)NULL)
  78.         return( FALSE );
  79.  
  80.     x = twin->_firstch[lineno];
  81.     endx = twin->_lastch[lineno];
  82.     dstp = curscr->_y[lineno] + x;
  83.     srcp = twin->_y[lineno] + x;
  84.     len = endx-x+1;
  85.  
  86.     ch = temp_line; /* now have ch pointing to area to contain real attributes. MH-920715 */
  87.  
  88.         memcpy(ch, srcp, len * sizeof(chtype));
  89.  
  90. /* replace the attribute part of the chtype with the actual colour value */
  91. /* replacing the number that points to the actual colour value.          */
  92. #ifndef UNIX
  93.     for (j=0;j<len;j++)          /* for each chtype in the line... */
  94.        {
  95.         chr = temp_line[j] & A_CHARTEXT;
  96.         temp_line[j] = chtype_attr(temp_line[j]) | chr;
  97.        }
  98. #endif
  99.  
  100.     if (_cursvar.direct_video)
  101.     {
  102.  
  103.         memcpy(dstp, srcp, len * sizeof(chtype));
  104.  
  105. #ifdef    FLEXOS
  106.         _split_plane(curscr, &line[0], &attr[0], lineno, x, lineno, endx);
  107.  
  108.         drect.r_row = lineno;
  109.         drect.r_col = x;
  110.         drect.r_nrow = 1;
  111.         drect.r_ncol = len;
  112.  
  113.         sframe.fr_pl[0] = (UBYTE *) line;
  114.         sframe.fr_pl[1] = (UBYTE *) attr;
  115.         sframe.fr_nrow = 1;
  116.         sframe.fr_ncol = len;
  117.         sframe.fr_use = 0x03;
  118.  
  119.         srect.r_col = 0;
  120.         srect.r_row = 0;
  121.         srect.r_nrow = 1;
  122.         srect.r_ncol = len;
  123.  
  124.         s_copy(0x03, 0x01L, 0L, (far unsigned short *) &drect,
  125.             (far unsigned short *) &sframe, (far unsigned
  126.             short *) &srect);
  127.  
  128. #endif
  129.  
  130. #ifdef    DOS
  131. #  ifdef GO32
  132.         dosmemput (ch, len * sizeof(chtype),
  133.             (void *)_FAR_POINTER(_cursvar.video_seg,
  134.             _cursvar.video_ofs + (((lineno * curscr->_maxx) + x) * sizeof(chtype))));
  135. #  else
  136. #    if    SMALL || MEDIUM
  137.         segread(&segregs);
  138.         ds = segregs.ds;
  139.         movedata(ds,(int)ch,
  140.             _cursvar.video_seg,
  141.             _cursvar.video_ofs+(((lineno*curscr->_maxx)+x)*sizeof(chtype)),
  142.                 len * sizeof(chtype));
  143. #    else
  144.         memcpy((void *)_FAR_POINTER(_cursvar.video_seg,
  145.                  _cursvar.video_ofs + (((lineno * curscr->_maxx) + x) * sizeof(chtype))),
  146.                ch, len * sizeof(chtype));
  147. #    endif
  148. #  endif
  149. #endif
  150.  
  151. #ifdef    OS2
  152.                     VioWrtCellStr ((PCH)ch, (USHORT)(len*sizeof(chtype)), (USHORT)lineno, (USHORT)x, 0);
  153. #endif
  154.     }
  155.     else
  156.     {
  157.  
  158. #ifdef UNIX
  159.         PDC_gotoxy(lineno,x);
  160.         for (; x <= endx; x++)
  161.         {
  162.             PDC_putc( (*ch & A_CHARTEXT),(*ch & A_ATTRIBUTES) );
  163.             ch++;
  164.         }
  165. #else
  166.         for (; x <= endx; x++)
  167.         {
  168.             PDC_gotoxy(lineno, x);
  169.             PDC_putc( (*ch & A_CHARTEXT),(*ch & A_ATTRIBUTES) >> 8 );
  170.             ch++;
  171.         }
  172. #endif
  173.     }
  174.     twin->_firstch[lineno] = _NO_CHANGE;
  175.     twin->_lastch[lineno] = _NO_CHANGE;
  176.  
  177.     if (_cursvar.refrbrk && PDC_check_bios_key())
  178.         return(TRUE);
  179.      else
  180.         return(FALSE);
  181. }
  182.